package corewarsxxi.logic;

import corewarsxxi.logic.throwables.processHalt;
import corewarsxxi.logic.throwables.processJump;
import java.io.Serializable;

/**
 * Abstract class <code>OpCode</code> that will be extended to implement
 * Core Wars instruction set.
 *
 * @version 1.0
 * @see     corewarsxxi.logic.add
 * @see     corewarsxxi.logic.cmp
 * @see     corewarsxxi.logic.dat
 * @see     corewarsxxi.logic.djn
 * @see     corewarsxxi.logic.jmn
 * @see     corewarsxxi.logic.jmp
 * @see     corewarsxxi.logic.jmz
 * @see     corewarsxxi.logic.mov
 * @see     corewarsxxi.logic.nop
 * @see     corewarsxxi.logic.slt
 * @see     corewarsxxi.logic.spl
 * @see     corewarsxxi.logic.sub
 * @author  Luís Fonseca, ei10139 @ FEUP
 */
public abstract class OpCode implements Serializable
{
    /**
     * Used to return the active Core instance.
     * @return the core instance
     */
    protected Core getCore()
    {
        return Core.getInstance();
    }

    /**
     *
     * @param aField
     * @param bField
     * @throws processHalt
     * @throws processJump
     */
    public abstract void operation(MemoryField aField, MemoryField bField) throws processHalt, processJump;

    /**
     * Makes use of the Singleton pattern and returns the public static OpCode object.
     * @return it<i>self</i>.
     */
    public abstract OpCode getSelf();
}
